package com.qing.library_manager.controller.manger;

import com.qing.library_manager.domain.dto.ManagerLoginDTO;
import com.qing.library_manager.domain.dto.ManagerResgisterDTO;
import com.qing.library_manager.service.manager.manager.managerService;
import com.qing.library_manager.common.util.ResponseResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

/**
 * <p>TODO</p>
 *
 * @author Yjx
 * @version 1.0.0
 * @since 2021/11/25
 **/

@RestController
@RequestMapping("/api/manager")
@Api(tags = {"管理员模块"})
public class managerController {

    private final managerService managerService;

    public managerController(managerService managerService) {
        this.managerService = managerService;
    }

    /**
     *  管理员登录
     * @param managerLoginDTO
     * @return
     */
    @ApiOperation("管理员登陆")
    @PostMapping("/managerLogin")
//    @PreAuthorize("@managerLogin.mangerLogin(managerLoginDTO)")
    public ResponseResult managerLogin(@RequestBody ManagerLoginDTO managerLoginDTO) {
        return managerService.mangerLogin(managerLoginDTO);
    }

    /**
     *  添加管理员
     * @param managerLoginDTO
     * @return
     */
    @ApiOperation("添加管理员")
    @PostMapping("/addManager")
    public ResponseResult addManager(@RequestBody ManagerLoginDTO managerLoginDTO) {
        return managerService.managerAdd(managerLoginDTO);
    }

}
